package bishi.wangyi;

import java.util.*;

public class demo1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        while (in.hasNext()) {
            String s = in.nextLine();
            Stack<Character> left = new Stack<>();
            Stack<Character> right = new Stack<>();
            int flg = 0;

            for (int i = 0; i < s.length(); i++) {
                char temp = s.charAt(i);

                if (temp == '(' || temp == '<') {
                    left.push(temp);
                } else {
                    right.push(temp);
                }

                if (temp == ')') {
                    if (left.isEmpty()) {
                        System.out.println("false");
                        flg = 1;
                        break;
                    }
                    right.pop();

                    char demo = left.pop();
                    if (demo != '(') {
                        System.out.println("false");
                        flg = 1;

                        break;
                    }

                }

                if (temp == '>') {

                    if (left.isEmpty()) {
                        System.out.println("false");
                        flg = 1;

                        break;
                    }
                    right.pop();

                    char demo = left.pop();
                    if (demo != '<') {
                        System.out.println("false");
                        flg = 1;

                        break;
                    }

                }

                if (temp == '*') {
                    if (left.isEmpty()) {
                        System.out.println("false");
                        flg = 1;

                        break;
                    }
                    right.pop();

                    left.pop();
                }

            }

            if(flg == 0){
                if (!left.isEmpty() || !right.isEmpty()) {
                    System.out.println("false");

                } else {
                    System.out.println("true");
                }
            }

        }


    }
}
